package com.dushibao.manage.menu;

import com.dushibao.service.MenuService;
import com.dushibao.service.impl.MenuServiceImpl;
import com.dushibao.utils.Page;
import com.dushibao.view.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/menu/list")
public class ListServlet extends HttpServlet {
    MenuService menuService = new MenuServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String current = req.getParameter("current");
        String pageSize = req.getParameter("pageSize");
        String menuName = req.getParameter("menuName");
        String menuUrl = req.getParameter("menuUrl");

        Page page = new Page();
        page.setCurrent(Integer.parseInt(current==null?"1":current));
        page.setPageSize(Integer.parseInt(pageSize==null?"10":pageSize));

        Page iPage = menuService.page(page,menuName,menuUrl);
        Map<String,Object> maps = new HashMap<>();
        maps.put("iPage",iPage);
        maps.put("menuName",menuName);
        maps.put("menuUrl",menuUrl);

        ModelAndView mv = new ModelAndView("menu/list",maps);

    }
}
